﻿$(function() {
    $(".ItemContent").each(function(i) {
        $(this).click(function() {//level_
            //break----用return false; 
            //continue --用return ture;
            var conbox = $(this).parents();
            var petid = conbox.attr("id");
            //debugger; //━╋
            if ("level_" + conbox.children("input").val() == petid) {
                var curspan = "#" + petid + "_son";
                if ($(curspan).hasClass("on")) {
                    $(curspan).removeClass("on");
                    $(curspan).addClass("uon");
                    $("#" + petid).find("img").attr("src", "/hgmanage/images/tree_open.gif");
                }
                else {
                    if ($("#" + petid + "_son").hasClass("uon")) {
                        $("#" + petid + "_son").removeClass("uon");
                        $("#" + petid + "_son").addClass("on");
                        $("#" + petid).find("img").attr("src", "/hgmanage/images/tree_close.gif");
                    }
                }
                return false; //break
            }
        });
    });

    $("input[type='radio']").click(function() {
        if (this.checked) {
            $("#HiddenID").val(this.value);
        }
    });
});

///////****类别上下移动****////
//上移事件
var selectvalue = "";
function moveup(type) {
    var url = "/hgmanage/";
    switch (type) {
        case "news": url += "news/newsclass.aspx"
            break;
        case "cate": url += "hgclass/category.aspx";
        default: break;
    }
    selectvalue = $("input:checked").val();
    if (!selectvalue) {
        alert("请先选择要操作的信息!");
        return false;
    }
    else {
        PageMethods.MoveUp(selectvalue, function(result) {
            if (result) {
                selectvalue = "";
                location.href = url;
            }
            else {
                alert("已经为最前排列了,不能上移了!");
            }
        });
        return false;
    }
}
//下移事件
function movedown(type) {
    var url = "/hgmanage/";
    switch (type) {
        case "news": url += "news/newsclass.aspx"
            break;
        case "cate": url += "hgclass/category.aspx";
        default: break;
    }

    selectvalue = $("input:checked").val();
    if (!selectvalue) {
        alert("请先选择要操作的信息!");
        return false;
    }
    else {
        PageMethods.MoveDown(selectvalue, function(result) {
            if (result) {
                selectvalue = "";
                location.href = url;
            }
            else {
                alert("已经为最后排列了,不能上移了!");
            }
        });
        return false;
    }
}

var delflag = true;
function del() {
    if (delflag) {
        return confirm("确定要删除选中数据吗?");
    }
    else {
        return false;
    }
}

function DelEvent() {
    var bln = true;
    var value = $("#HiddenID").val();
    if (!value) {
        alert("请先选择要操作的一条数据!");
        return false;
    }
    else {
        PageMethods.IsEffective(value, function(result) {
            switch (result) {
                case 0:
                    delflag = true;
                    break;
                case 1:
                    alert("该类别有下级类别,不能直接删除!");
                    delflag = false;
                    break;
                case 2:
                    alert("该类别已有内容信息,不能直接删除!");
                    delflag = false;
                    break;
                default: break;
            }
        });
    }
}
function SelectEvent() {
    var value = $("#HiddenID").val();
    if (!value) {
        alert("请先选择要操作的一条数据!");
        return false;
    }
    return true;
}